/// 护士执行参数
Class Nur.MNISV3.Service.OrderParam Extends %RegisteredObject
{

/// 安全组ID
Property groupID As %String;

/// 开单科室类型
Property ordDepType As %String;

/// 查询开始日期
Property startDate As %String;

/// 查询开始时间
Property startTime As %String;

/// 查询结束日期
Property endDate As %String;

/// 查询结束时间
Property endTime As %String;

/// 医院ID
Property hospID As %String;

/// 病区ID
Property wardID As %String;

/// 科室ID
Property locID As %String;

/// 要求执行时间为false、开医嘱时间为true
Property createOrderFlag As %String;

/// 医嘱类型默认为A
Property orderType As %String;

/// 筛选已执行为true、筛选未执行为false
Property excutedOrderFlag As %String;

/// 筛选已打印为true、筛选未打印为false
Property ifPrint As %String;

/// 筛选长期医嘱为true
Property longOrderFlag As %String;

/// 筛选临时医嘱为true
Property tempOrderFlag As %String;

/// 筛选今日新开医嘱为true
Property newCreateFlag As %String;

/// 筛选今日新停医嘱为true
Property newDisconFlag As %String;

/// 护士医嘱、医生医嘱
Property ctcptType As %String;

/// 科室类型
Property locType As %String;

/// 开医嘱日期
Property startCreateDate As %String;

/// 开医嘱时间
Property startCreateTime As %String;

/// 结束开医嘱日期
Property endCreateDate As %String;

/// 结束开医嘱时间
Property endCreateTime As %String;

/// 确认标识
Property confirmFlag As %String;

/// 预停医嘱筛选标识
Property preStopOrderFlag As %String;

/// /========================================start==============================================
Property PDAMulti As %Boolean;

Property PDAStart As %Integer;

Property PDALimit As %Integer;

Property PDAIndex As %Integer;

Property PDAAtEnd As %Boolean;

Property PDAScreenings;

Property PDABatch As %Boolean;

/// 闭环节点
Property PDANodes;

Property PDATest As %Boolean;

/// 返回数据格式
Property PDAGetOrder As %String;

Method CopyFrom(PDAParam) As %String
{
    s i%PDAMulti=PDAParam.PDAMulti
    s i%PDAStart=PDAParam.PDAStart
    s i%PDALimit=PDAParam.PDALimit
    s i%PDAScreenings=PDAParam.PDAScreenings
    s i%PDABatch=PDAParam.PDABatch
    s i%PDANodes=PDAParam.PDANodes
    s i%PDAGetOrder=PDAParam.PDAGetOrder
    s i%PDAIndex=0
    s i%PDAAtEnd=0
    q $this
}

Method PageFilter() As %String
{
    s i%PDAIndex=i%PDAIndex+1
    q:(i%PDAIndex<i%PDAStart) 0
    i (i%PDAIndex>i%PDALimit) s i%PDAAtEnd=1 q 0
    q 1
}

Method PDAFilter(oew, chl, sub, filterInfo, currentSheetSetting) As %String
{
    s oeoriId=oew_"||"_chl
    i (sub'="") {
        s oeoreId=oeoriId_"||"_sub
        i (i%PDANodes'="") { //TODO
            q:('$classmethod("Nur.MNISV4.Module.OrderExecute.Service","TryOCLNodeId",oeoreId,i%PDANodes)) 0
        }
    }
    i (i%PDAScreenings'="") {
        s str=i%PDAScreenings
        s len=$l(str,"^")
        f ind=1:1:len {
            s item=$p(str,"^",ind)
            s code=$p(item,"|"),opts=$p(item,"|",2) //TODO
            return:('..Determine(oeoriId,code,opts)) 0
        }
    }
    q 1
}

ClassMethod Determine(oeoriId, code, opts) As %String
{
    i (code="oecprDesc") { 
        //s isLong=$classmethod("Nur.MNISV4.Entity.Business.Order","IsLong",oeoriId)
        s isLong=##class(appcom.OEOrdItem).ISLongOrderPrior(oeoriId)
        //s isTemp=$classmethod("Nur.MNISV4.Entity.Business.Order","IsTemp",oeoriId)
        s isTemp=##class(appcom.OEOrdItem).ISShortOrderPrior(oeoriId)
        i (isLong) s desc="长期"
        e  i (isTemp) s desc="临时"
        e  s desc="其他"
        q:(opts'[desc) 0
    } elseif (code="ordType") { //TODO
        s isDrug=$classmethod("Nur.MNISV4.Entity.Business.Order","IsDrugLinkSub",oeoriId)
        //s isLab=$classmethod("Nur.MNISV4.Entity.Business.Order","IsLab",oeoriId)
        s isLab=(..IsLIS(oeoriId))||(..IsPIS(oeoriId))
        i (isDrug) s desc="药品"
        e  i (isLab) s desc="检验"
        e  s desc="其他"
        q:(opts'[desc) 0
    }
    q 1
}

ClassMethod IsLIS(oeoriId) As %String
{
    s oew=+oeoriId,chl=$p(oeoriId,"||",2)
    q $p($g(^OEORD(oew,"I",chl,3)),"^",20)'=""
}

ClassMethod IsPIS(oeoriId) As %String
{
    s oew=+oeoriId,chl=$p(oeoriId,"||",2)
    s pisId=$o(^DHCAPPPM(0,"OrdItem",oew_"||"_chl,""))
    q:(pisId="") 0
    s pisInfo=##Class(web.DHCAPPPisInterface).GetSpeNameByRepID(pisId)
    s count=$l(pisInfo,";")
    f index=1:1:count {
        s piece=$p(pisInfo,";",index)
        return:($p(piece,"!",5)'="") 1
    }
    q 0
}

/// /========================================end==============================================
Method preStopOrderFlagSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%preStopOrderFlag = Arg
    Quit $$$OK
}

Method preStopOrderFlagGet() As %String [ ServerOnly = 1 ]
{
    Quit i%preStopOrderFlag
}

Method groupIDGet() As %String [ ServerOnly = 1 ]
{
    Quit i%groupID
}

Method groupIDSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%groupID = Arg
    Quit $$$OK
}

Method ordDepTypeGet() As %String [ ServerOnly = 1 ]
{
    Quit i%ordDepType
}

Method ordDepTypeSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%ordDepType = Arg
    Quit $$$OK
}

Method startDateGet() As %String [ ServerOnly = 1 ]
{
    Quit i%startDate
}

Method startDateSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%startDate = Arg
    Quit $$$OK
}

Method startTimeGet() As %String [ ServerOnly = 1 ]
{
    Quit i%startTime
}

Method startTimeSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%startTime = Arg
    Quit $$$OK
}

Method endDateGet() As %String [ ServerOnly = 1 ]
{
    Quit i%endDate
}

Method endDateSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%endDate = Arg
    Quit $$$OK
}

Method endTimeGet() As %String [ ServerOnly = 1 ]
{
    Quit i%endTime
}

Method endTimeSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%endTime = Arg
    Quit $$$OK
}

Method hospIDGet() As %String [ ServerOnly = 1 ]
{
    Quit i%hospID
}

Method hospIDSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%hospID = Arg
    Quit $$$OK
}

Method wardIDGet() As %String [ ServerOnly = 1 ]
{
    Quit i%wardID
}

Method wardIDSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%wardID = Arg
    Quit $$$OK
}

Method locIDGet() As %String [ ServerOnly = 1 ]
{
    Quit i%locID
}

Method locIDSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%locID = Arg
    Quit $$$OK
}

Method createOrderFlagGet() As %String [ ServerOnly = 1 ]
{
    Quit i%createOrderFlag
}

Method createOrderFlagSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%createOrderFlag = Arg
    Quit $$$OK
}

Method orderTypeGet() As %String [ ServerOnly = 1 ]
{
    Quit i%orderType
}

Method orderTypeSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%orderType = Arg
    Quit $$$OK
}

Method excutedOrderFlagGet() As %String [ ServerOnly = 1 ]
{
    Quit i%excutedOrderFlag
}

Method excutedOrderFlagSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%excutedOrderFlag = Arg
    Quit $$$OK
}

Method ifPrintGet() As %String [ ServerOnly = 1 ]
{
    Quit i%ifPrint
}

Method ifPrintSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%ifPrint = Arg
    Quit $$$OK
}

Method longOrderFlagGet() As %String [ ServerOnly = 1 ]
{
    Quit i%longOrderFlag
}

Method longOrderFlagSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%longOrderFlag = Arg
    Quit $$$OK
}

Method tempOrderFlagGet() As %String [ ServerOnly = 1 ]
{
    Quit i%tempOrderFlag
}

Method tempOrderFlagSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%tempOrderFlag = Arg
    Quit $$$OK
}

Method newCreateFlagGet() As %String [ ServerOnly = 1 ]
{
    Quit i%newCreateFlag
}

Method newCreateFlagSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%newCreateFlag = Arg
    Quit $$$OK
}

Method newDisconFlagGet() As %String [ ServerOnly = 1 ]
{
    Quit i%newDisconFlag
}

Method newDisconFlagSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%newDisconFlag = Arg
    Quit $$$OK
}

Method ctcptTypeGet() As %String [ ServerOnly = 1 ]
{
    Quit i%ctcptType
}

Method ctcptTypeSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%ctcptType = Arg
    Quit $$$OK
}

Method locTypeGet() As %String [ ServerOnly = 1 ]
{
    Quit i%locType
}

Method locTypeSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%locType = Arg
    Quit $$$OK
}

Method startCreateDateGet() As %String [ ServerOnly = 1 ]
{
    Quit i%startCreateDate
}

Method startCreateDateSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%startCreateDate = Arg
    Quit $$$OK
}

Method startCreateTimeGet() As %String [ ServerOnly = 1 ]
{
    Quit i%startCreateTime
}

Method startCreateTimeSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%startCreateTime = Arg
    Quit $$$OK
}

Method endCreateDateGet() As %String [ ServerOnly = 1 ]
{
    Quit i%endCreateDate
}

Method endCreateDateSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%endCreateDate = Arg
    Quit $$$OK
}

Method endCreateTimeGet() As %String [ ServerOnly = 1 ]
{
    Quit i%endCreateTime
}

Method endCreateTimeSet(Arg As %String) As %Status [ ServerOnly = 1 ]
{
    s i%endCreateTime = Arg
    Quit $$$OK
}

}
